#!/bin/sh -e

ver=$(cut -f1 d' ' $($(dirname $0)/version))

# If no user provided .config, generate one. 
if [ ! -s .config ]; then
    make defconfig
    make localyesconfig
    sed -i '/ATH5K/{s/^# //;s/ is not set.*//;s/.*/&=y/p}' .config
    cp .config `kiss s linux-libre-kernel | sed 1q`/files/.config
fi

make -j`nproc`

make INSTALL_MOD_STRIP=1 modules_install
make install

mv /boot/vmlinuz /boot/vmlinuz-$ver
mv /boot/System.map /boot/System.map-$ver
